{extend name="index_base" /}
      {block name="seo"}
        <title>用户设置|{$site_config['site_title']}|{$site_config['seo_title']}</title>
  
  
  <meta name="keywords" content="{$site_config['seo_keyword']}">
  <meta name="description" content="{$site_config['seo_description']}">
      {/block}
{block name="body"}
<div class="fly-user-main">
  <ul class="layui-nav layui-nav-tree layui-inline" lay-filter="user">
    <li class="layui-nav-item">
      <a href="{:url('user/home',array('id'=>$uid))}">
        <i class="layui-icon">&#xe609;</i>
        我的主页
      </a>
    </li>
    <li class="layui-nav-item">
      <a href="{:url('user/topic')}">
        <i class="layui-icon">&#xe612;</i>
        我的帖子
      </a>
    </li>
     <li class="layui-nav-item">
      <a href="{:url('user/comment')}">
        <i class="layui-icon">&#xe63c;</i>
        我的回复
      </a>
    </li>
    <li class="layui-nav-item">
      <a href="{:url('user/message')}">
        <i class="layui-icon">&#xe611;</i>
        我的消息
      </a>
    </li>
    <li class="layui-nav-item layui-this">
      <a href="{:url('user/set')}">
        <i class="layui-icon">&#xe620;</i>
        基本设置
      </a>
    </li>
    
  </ul>
  
  <div class="site-tree-mobile layui-hide">
    <i class="layui-icon">&#xe602;</i>
  </div>
  <div class="site-mobile-shade"></div>
  
  <div class="fly-panel fly-panel-user" pad20>
    <div class="layui-tab layui-tab-brief" lay-filter="user">
      <ul class="layui-tab-title" id="LAY_mine">
        <li class="layui-this" lay-id="info">我的资料</li>
        <li lay-id="avatar">头像</li>
        <li lay-id="pass">密码</li>
        <li lay-id="bind" >帐号绑定</li>
      </ul>
      <div class="layui-tab-content" style="padding: 20px 0;">
        <div class="layui-form layui-form-pane layui-tab-item layui-show">
          <form method="post">
            <div class="layui-form-item">
              <label for="L_email" class="layui-form-label">邮箱</label>
              <div class="layui-input-inline">
                <input type="text" id="L_email" name="usermail" required lay-verify="email" autocomplete="off"  value="{$tptc.usermail}"  class="layui-input"  {if condition="($tptc.status eq 2) OR ($tptc.status eq 5)"}disabled{/if} >
              </div>
              {if condition="($tptc.status eq 2) OR ($tptc.status eq 5)"}
               <div class="layui-form-mid layui-word-aux">如果您在邮箱已激活的情况下，变更了邮箱，需
              <a href="javascript:;" style="font-size: 12px; color: #4f99cf;"  id="rejhemail">重新验证邮箱</a>。</div>
              {else /}
              <div  class="layui-form-mid layui-word-aux"><a href="javascript:;"  style="font-size: 12px; color: #4f99cf;" id="jhemail">激活邮箱</a>。</div>
             
              {/if}
              
              
            </div>
            <div class="layui-form-item">
              <label for="L_username" class="layui-form-label">昵称</label>
              <div class="layui-input-inline">
                <input type="text" id="L_username" name="username" required lay-verify="required" value="{$tptc.username}"  autocomplete="off" value="" class="layui-input">
              </div>
              <div class="layui-inline">
                <div class="layui-input-inline">
                 <input type="radio" name="sex" value="1" title="男" {if condition="$tptc['sex'] eq 1"}checked{/if}>
					  <input type="radio" name="sex" value="0" title="女" {if condition="$tptc['sex'] eq 0"}checked{/if}>
                </div>
              </div>
            </div>
            <div class="layui-form-item">
              <label for="L_city" class="layui-form-label">城市</label>
              <div class="layui-input-inline">
                <input type="text" id="L_city" name="userhome" value="{$tptc.userhome}"  autocomplete="off" value="" class="layui-input">
              </div>
            </div>
            {:hook('showpay')}	
            <div class="layui-form-item layui-form-text">
              <label for="L_sign" class="layui-form-label">签名</label>
              <div class="layui-input-block">
                <textarea placeholder="随便写些什么刷下存在感" id="L_sign"  name="description" autocomplete="off" class="layui-textarea" style="height: 80px;">{$tptc.description}</textarea>
              </div>
            </div>
            <div class="layui-form-item">
              <button class="layui-btn" key="set-mine"  lay-filter="user_set" lay-submit>确认修改</button>
            </div>
          </div>
          
          <div class="layui-form layui-form-pane layui-tab-item">
        <form method="post">
			<div class="layui-form-item">
              <div class="avatar-add">
                <p>建议尺寸168*168，支持jpg、png、gif，最大不能超过50KB</p>
                <div class="upload-img">
				 
                  <input type="file" name="file" class="layui-upload-file" id="image" lay-type="images">
	              <input type="hidden" name="userhead" value="{$tptc.userhead}" class="layui-input">
                </div>
                <img id="headedit" src="{$tptc.userhead|getheadurl}">
              </div>
            </div>
			<div class="layui-form-item">
            <button class="layui-btn" lay-submit="" lay-filter="user_headedit">确认修改</button>
            </div>
			</form>
          </div>
          
          <div class="layui-form layui-form-pane layui-tab-item">
            <form  method="post">
            
            {if condition="$tptc.password neq 0"}
              <div class="layui-form-item">
                <label for="L_nowpass" class="layui-form-label">当前密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_nowpass" name="nowpass" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
              </div>
              {else /}
              <input type="hidden" value="0"  name="nowpass" >
              {/if}
              <div class="layui-form-item">
                <label for="L_pass" class="layui-form-label">新密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_pass" name="password" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">6到16个字符</div>
              </div>
              <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">确认密码</label>
                <div class="layui-input-inline">
                  <input type="password" id="L_repass" name="confirm_password" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
              </div>
              <div class="layui-form-item">
                <button class="layui-btn" key="set-mine"  lay-filter="user_setedit" lay-submit>确认修改</button>
              </div>
            </form>
          </div>
          
          <div class="layui-form layui-form-pane layui-tab-item">
            <ul class="app-bind">
                {:hook('bindqq')}
            </ul>
          </div>
        </div>

      </div>
    </div>
  </div>
{/block}
{block name="script"}
<script>

layui.use(['form', 'upload', 'element'],function(){
  var form = layui.form()
  ,element = layui.element()
  ,jq = layui.jquery;
var n=1;
  jq('.site-tree-mobile').click(function(){
	  
	  if( n==2){
		  jq('.layui-nav').animate({left: '-300px'}, "fast");
		 jq(this).find('.layui-icon').html('&#xe602;');
		  n=1;
	  }else{
		  n=2;
		  jq('.layui-nav').animate({left: '0px'}, "fast");
		  jq(this).find('.layui-icon').html('&#xe603;');
	  }
	 

	  
  });
  
  
  layui.upload({
    url: '{:url("upload/upimage")}'
    ,elem:'#image'
	,ext: 'jpg|png|gif'
	
	,area: ['100px', '100px']
    ,before: function(input){
    	
    	
      loading = layer.load(2, {
        shade: [0.2,'#000'] //0.2透明度的白色背景
      });
    }
    ,success: function(res){
      layer.close(loading);
     
   
      jq('input[name=userhead]').val(res.path);
	 headedit.src = res.headpath;
	
	//  headedit.src = res.info;
      layer.msg(res.msg, {icon: 1, time: 1000});
    }
  }); 
  jq('#jhemail').click(function(){
	  //激活邮箱直接变成disable，然后发送邮件。邮件验证成功后，该status变为2或者5
	   var email=jq('#L_email').val();
		 var url="{:url('index/yzemail')}"; 
		
		  if(email==''){
			  layer.msg('邮箱不能为空', {icon: 2, anim: 6, time: 1000});
			  return false;
		  }
		  
		  
		    jq.post(url,{'email':email},function(data){
			      if(data.code == 1){
			      
			        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
			         // 
			        
			        	 jq('#L_email').attr('disabled','disabled');
			      
			          
			        });
			      }else{
			      
			        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
			      }
			    });
 });
  var emailold='';
  
  jq('#rejhemail').click(function(){
	  //重新激活邮箱后，去掉disable,然后传送email的参数
		//  var id= jq(this).data('id');
	  	var url="{:url('index/reyzemail')}"; 
	  
	  if(jq(this).html()=='立即激活'){
		  var reemail=jq('#L_email').val();
		  if(reemail==emailold){
			  layer.msg('请更改邮箱进行验证', {icon: 2, anim: 6, time: 1000});
		  }else{
			  jq.post(url,{'email':reemail},function(data){
			      if(data.code == 1){
			      
			        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
			         // 
			        	
			        	 jq('#L_email').attr('disabled','disabled');
					      
			      
			          
			        });
			      }else{
			      
			        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
			      }
			    });
		  }
		  
		  
	  }else{
			emailold=jq('#L_email').val();
			jq('#L_email').removeAttr('disabled');
			jq(this).html('立即激活');
		  
	  }
	  
 });
  
  

  form.on('submit(user_set)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("user/set")}',param,function(data){
      if(data.code == 200){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          location.href = '{:url("user/set")}';
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });

  form.on('submit(user_setedit)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("index/user/setedit")}',param,function(data){
      if(data.code == 200){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          location.href = '{:url("user/set")}';
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });

  form.on('submit(user_headedit)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    console.log(data);
    var param = data.field;
    jq.post('{:url("index/user/headedit")}',param,function(data){
      if(data.code == 200){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          location.href = '{:url("user/set")}';
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
  
});
</script>{/block}